package com.gwg.service.impl;

import com.fly.common.idworker.IdWorker;
import com.fly.common.model.OrderEntity;
import com.gwg.dao.DemoDao;
import com.gwg.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @description
 * @author: liying.fu
 * @Date: 2018/11/25 下午12:51
 */
@Service
public class DemoServiceImpl implements DemoService {

    @Autowired
    private DemoDao demoDao;

    @Autowired
    private IdWorker idWorker;

    @Override
    public void save(OrderEntity orderEntity) {
        orderEntity.setOrderId(idWorker.nextId());
        demoDao.insert(orderEntity);

        int i = demoDao.countDemo();
        System.out.println("--------------->" + i);
    }

    @Override
    public void delete(Long orderId){
        demoDao.deleteById(orderId);
    }
    @Override
    public OrderEntity select(Long orderId){
      return  demoDao.selectById(orderId);
    }
    @Override
    public void update(OrderEntity orderEntity){
        demoDao.updateById(orderEntity);
    }
}
